package com.ruoyi.sys.vehile.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sys.vehile.domain.TbTemporaryPayment;
import com.ruoyi.sys.vehile.service.ITbTemporaryPaymentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 临停缴费Controller
 *
 * @author ruoyi
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/payment")
public class TbTemporaryPaymentController extends BaseController
{
    @Autowired
    private ITbTemporaryPaymentService tbTemporaryPaymentService;

    /**
     * 查询临停缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:payment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbTemporaryPayment tbTemporaryPayment)
    {
        startPage();
        List<TbTemporaryPayment> list = tbTemporaryPaymentService.selectTbTemporaryPaymentList(tbTemporaryPayment);
        return getDataTable(list);
    }

    /**
     * 导出临停缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:payment:export')")
    @Log(title = "临停缴费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTemporaryPayment tbTemporaryPayment)
    {
        List<TbTemporaryPayment> list = tbTemporaryPaymentService.selectTbTemporaryPaymentList(tbTemporaryPayment);
        ExcelUtil<TbTemporaryPayment> util = new ExcelUtil<TbTemporaryPayment>(TbTemporaryPayment.class);
        util.exportExcel(response, list, "临停缴费数据");
    }

    /**
     * 获取临停缴费详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:payment:query')")
    @GetMapping(value = "/{tpId}")
    public AjaxResult getInfo(@PathVariable("tpId") Long tpId)
    {
        return AjaxResult.success(tbTemporaryPaymentService.selectTbTemporaryPaymentByTpId(tpId));
    }

    /**
     * 新增临停缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment:add')")
    @Log(title = "临停缴费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbTemporaryPayment tbTemporaryPayment)
    {
        return toAjax(tbTemporaryPaymentService.insertTbTemporaryPayment(tbTemporaryPayment));
    }

    /**
     * 修改临停缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment:edit')")
    @Log(title = "临停缴费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbTemporaryPayment tbTemporaryPayment)
    {
        return toAjax(tbTemporaryPaymentService.updateTbTemporaryPayment(tbTemporaryPayment));
    }

    /**
     * 删除临停缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment:remove')")
    @Log(title = "临停缴费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tpIds}")
    public AjaxResult remove(@PathVariable Long[] tpIds)
    {
        return toAjax(tbTemporaryPaymentService.deleteTbTemporaryPaymentByTpIds(tpIds));
    }
}
